package com.example.demo.service;

import com.example.demo.mapper.StudentMapper;
import com.example.demo.pojo.Classes;
import com.example.demo.pojo.Course;
import com.example.demo.pojo.Student;
import com.example.demo.vo.Students;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentMapper studentMapper;

    @Override
    public List<Student> queryStudent() {
       return studentMapper.queryStudent();
    }

    @Override
    public void addStudent(String student_name, int student_number, String student_sex, int student_age, int class_id) {
        studentMapper.addStudent(student_name,student_number,student_sex,student_age,class_id);
    }

    @Override
    public void updateStudent(Student student) {
        studentMapper.updateStudent(student);
    }

    @Override
    public void deleteStudent(int id) {
        studentMapper.deleteStudent(id);
    }

    @Override
    public String add(Students students) {
        int add = studentMapper.add(students);
       // Integer id = students.getId();
        Classes classes=new Classes();
       // int class_id = students.getClass_id();

        classes.setId(students.getClass_id());
        //studentMapper.addClassesId(classes);
        if (add>0){
            return "设置班级成功";
        }
        return "设置班级失败";
    }
}
